<style lang="less">
  @import './login.less';
</style>
<template>
  <div class="loginPage">
    <div class="loginMain">
    <div class="title">
      <h2 class="bigtitle">商户登录</h2>
      <p>代付</p>
    </div>
    <div class="loginfrom">
      <login-form  @on-success-valid="handleSubmit"></login-form>
    </div>
  </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),

    handleSubmit ({ userName, password, user_type, vcode }) {
      this.handleLogin({ userName, password, user_type, vcode }).then(res => {
        this.$Message.success(res.msg)
        this.getUserInfo().then(res => {
          this.$router.push({
            name: 'home'
          })
        }).catch(res => {
          this.$Message.error(res.msg)
        })
      }).catch(res => {
        this.$Message.error(res.msg)
      })
    }
  }
}
</script>

<style>

</style>
